import Vue from 'vue'
import App from './App.vue'
import router from './router'
import Antd from 'ant-design-vue';
import http from './tools/http'
import filter from './tools/filters'
import utils from './tools/utils'
import mavonEditor from 'mavon-editor'

import 'normalize.css'
import 'ant-design-vue/dist/antd.css'; // or 'ant-design-vue/dist/antd.less'
import 'mavon-editor/dist/css/index.css'
Vue.config.productionTip = false

Vue.mixin(filter)
Vue.use(Antd);
Vue.use(mavonEditor)
Vue.prototype.Util = utils
Vue.prototype.Http = http

Vue.directive('ButtonPermission', {
  // 当被绑定的元素插入到 DOM 中时……
  inserted: function (el, binding) {
    // 取值
    const ButtonName = binding.value.ButtonName
    const stroage = typeof sessionStorage.getItem('LOGIN_INFO') == 'string' && sessionStorage.getItem('LOGIN_INFO')
      ? JSON.parse(sessionStorage.getItem('LOGIN_INFO')).button : ""
    if (!stroage) {
      return
    }
    Object.values(stroage).forEach(item => {
      item.forEach(button => {
        if (button.buttonName == ButtonName) {
          // 判断该按钮权限 true允许   false不允许
          let isDisabled = button.isHide
          // 聚焦元素
          if (!isDisabled) {
            el.disabled = true
            el.classList.add('is-hide')
          }
        }
      })
    })
  }
})

const app = new Vue({
  router,
  components: { App },
  template: '<App/>',
  render: h => h(App)
}).$mount('#app')

export default app
